﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
namespace FigureDraw
{
    public class GDIPlus : ScreenDevice
    {
        private Graphics graphics;
        private Pen pen;
        Form thisform;

        public Form Thisform
        {
            get { return thisform; }
            set { thisform = value; }
        }

        public GDIPlus(Graphics g, Pen p, Form f)
        {
            this.graphics = g;
            this.pen = p;
            this.thisform = f;
        }

        public GDIPlus()
        {
        }
        public override void drawLine(int x1, int y1, int x2, int y2)
        {
            graphics.DrawLine(pen, x1, y1, x2, y2);
        }

        public override void drawRect(int x, int y, int width, int height)
        {
            x = x - width / 2;
            y = y - height / 2;
            graphics.DrawRectangle(pen, (float)x, (float)y, (float)width, (float)height);
        }

        public override void drawEllipse(int x, int y, int width, int height)
        {
            x = x - width / 2;
            y = y - height / 2;
            graphics.DrawEllipse(pen, (float)x, (float)y, (float)width, (float)height);
        }
        public override void drawString(string s, Font font, PointF point)
        {
            throw new NotImplementedException();
        }
        public override void drawArrow(int x1, int y1, int x2, int y2)
        {
            Pen newpen = new Pen(Color.Red, 5);
            newpen.StartCap = LineCap.Round;
            newpen.EndCap = LineCap.ArrowAnchor;

            graphics.DrawLine(newpen, x1, y1, x2, y2);

            newpen.Dispose();
        }

        public override void drawCurve(Point[] arrPoint)
        {
            Pen newpen = new Pen(Color.Red, 5);
            newpen.StartCap = LineCap.Round;
            newpen.EndCap = LineCap.ArrowAnchor;
            
            graphics.DrawCurve(newpen, arrPoint);
            newpen.Dispose();
        }

        public override string ToString()
        {
            return "GDI Plus";
        }

        public override void setColor(int r, int g, int b)
        { 
            this.pen.Color = Color.FromArgb(r, g, b);
            
        }
        public override void setLineWidth(int lw)
        {
            this.pen.Width = lw;
        }
  





        public override void ClearAll()
        {
            graphics.Clear(System.Drawing.SystemColors.Menu);
        }

        #region "Property"
        public Graphics Graphics
        {
            get { return graphics; }
            set { graphics = value; }
        }


        public Pen Pen
        {
            get { return pen; }
            set { pen = value; }
        }
        #endregion
    }
}
